/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */

#include "int_contacts.h"

static void
my_hover_bt_1(void *data, Evas_Object *obj, void *event_info)
{
   Evas_Object *hv = data;
   
   evas_object_show(hv);
}

void manage_contact_cat()
{
}

void
index_changed2(void *data, Evas_Object *obj, void *event_info)
{
   // called on a change but delayed in case multiple changes happen in a
   // short timespan
   elm_genlist_item_top_bring_in(event_info);
}

void
index_changed(void *data, Evas_Object *obj, void *event_info)
{
   // this is calld on every change, no matter how often
   // elm_genlist_item_bring_in(event_info);
}

void
index_selected(void *data, Evas_Object *obj, void *event_info)
{
   // called on final select
   elm_genlist_item_top_bring_in(event_info);
}

char *gl_con_cat_label_get(const void *data, Evas_Object *obj, const char *part)
{
	_contact *con = (_contact *)data;
	char *ty;
	
	ty = strdup(con->name);
	return (ty);
}

Evas_Object *gl_con_cat_icon_get(const void *data, Evas_Object *obj, const char *part)
{
	char buf[255], buf1[255], buf2[255], buf3[255];
	_contact *con = (_contact *)data;
	
	if (!strcmp(part, "elm.swallow.icon"))
	{
		Evas_Object *ic = elm_icon_add(obj);
		Evas_Object *ic1 = elm_icon_add(obj);
		Evas_Object *ic2 = elm_icon_add(obj);
		Evas_Object *ic3 = elm_icon_add(obj);
		
		snprintf(buf, sizeof(buf), "/usr/share/launcher/family.png");
		snprintf(buf1, sizeof(buf1), "/usr/share/launcher/friends.png");
		snprintf(buf2, sizeof(buf2), "/usr/share/launcher/misc.png");
		snprintf(buf3, sizeof(buf3), "/usr/share/launcher/work.png");
		
		elm_icon_file_set(ic, buf, NULL);
		elm_icon_file_set(ic1, buf1, NULL);
		elm_icon_file_set(ic2, buf2, NULL);
		elm_icon_file_set(ic3, buf3, NULL);
		
		evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
		evas_object_size_hint_aspect_set(ic1, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
		evas_object_size_hint_aspect_set(ic2, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
		evas_object_size_hint_aspect_set(ic3, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
		
		if (strcmp(con->cat, "Family") == 0) return ic;
		if (strcmp(con->cat, "Friends") == 0) return ic1;
		if (strcmp(con->cat, "Misc") == 0) return ic2;
		if (strcmp(con->cat, "Work") == 0) return ic3;
		else return NULL;
	}
	return NULL;
}

Eina_Bool gl_con_cat_state_get(const void *data, Evas_Object *obj, const char *part)
{
   return 0;
}

void gl_con_cat_del(const void *data, Evas_Object *obj)
{
}

void set_contact_cat()
{
	Evas_Object *app_cat_win;
	app_cat_win = elm_win_add(NULL, "Set Categories", ELM_WIN_BASIC);
	elm_win_title_set(app_cat_win, "Set Categories");

	Evas_Object *bg, *vbox, *hbox, *fr;
	Evas_Object *cancel_button, *bt, *bx;
	static Winlist wl;

	//add background
	bg = elm_bg_add(app_cat_win);
	elm_win_resize_object_add(app_cat_win, bg);
	evas_object_size_hint_weight_set(bg, 1.0, 1.0);
	evas_object_show(bg);

	//add vbox
	vbox = elm_box_add(app_cat_win);
	elm_win_resize_object_add(app_cat_win, vbox);
	evas_object_size_hint_weight_set(vbox, 1.0, 1.0);
	evas_object_show(vbox);

	//add a hbox
	hbox = elm_box_add(app_cat_win);
	elm_box_horizontal_set(hbox, 1);
	evas_object_size_hint_weight_set(hbox, 1.0, 0.0);
	evas_object_size_hint_align_set(hbox, -1.0, 0.0);
	elm_box_pack_end(vbox, hbox);
	evas_object_show(hbox);
	
	//add a frame
	fr = elm_frame_add(app_cat_win);
	elm_object_style_set(fr, "outdent_top");
	evas_object_size_hint_weight_set(fr, 0.0, 0.0);
	evas_object_size_hint_align_set(fr, 0.0, -1.0);
	elm_box_pack_end(hbox, fr);
	evas_object_show(fr);

	//add a hbox
	hbox = elm_box_add(app_cat_win);
	elm_box_horizontal_set(hbox, 1);
	evas_object_size_hint_weight_set(hbox, 1.0, 0.0);
	evas_object_size_hint_align_set(hbox, -1.0, 0.0);
	elm_frame_content_set(fr, hbox);
	evas_object_show(hbox);

	//add a label
	app_lb = elm_label_add(app_cat_win);
	elm_label_label_set(app_lb, "Select Contacts for");
	elm_box_pack_end(hbox, app_lb);
	evas_object_show(app_lb);
	
	//add the category hover
	con_hv = elm_hover_add(app_cat_win);
	contact_cat_bt = elm_button_add(app_cat_win);
	elm_button_label_set(contact_cat_bt,"Category");
	evas_object_smart_callback_add(contact_cat_bt, "clicked", my_hover_bt_1, con_hv);
	evas_object_size_hint_weight_set(con_hv, 0.0, 0.0);
	evas_object_size_hint_align_set(con_hv, 0.5, 0.0);
	elm_box_pack_end(hbox, contact_cat_bt);
	evas_object_show(contact_cat_bt);
	elm_hover_parent_set(con_hv, app_cat_win);
	elm_hover_target_set(con_hv, contact_cat_bt);

	bt = elm_button_add(app_cat_win);
	elm_button_label_set(bt, "Category");
	elm_hover_content_set(con_hv, "middle", bt);
	evas_object_show(bt);

	bx = elm_box_add(app_cat_win);
	//add categories
	add_contact_hs_items (app_cat_win, bx, bt);
	evas_object_show(bx);
	elm_hover_content_set(con_hv, "bottom", bx); 
	
	//add a list
	con_list = elm_genlist_add(app_cat_win);
	elm_genlist_bounce_set(con_list, 0, 0);
	evas_object_size_hint_weight_set(con_list, 1.0, 1.0);
	evas_object_size_hint_align_set(con_list, -1.0, -1.0);
	elm_genlist_multi_select_set(con_list, 1);
	elm_box_pack_end(vbox, con_list);
	evas_object_show(con_list);
	//evas_object_smart_callback_add(list, "selected", app_select, list);

	//genlist class defs
	itc_con_cat.item_style     	= "default";
	itc_con_cat.func.label_get 	= gl_con_cat_label_get;
	itc_con_cat.func.icon_get  	= gl_con_cat_icon_get;
	itc_con_cat.func.state_get 	= gl_con_cat_state_get;
	itc_con_cat.func.del       	= gl_con_cat_del;

	//add index
	id = elm_index_add(app_cat_win);
	evas_object_size_hint_weight_set(id, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_win_resize_object_add(app_cat_win, id);
	evas_object_show(id);

	evas_object_smart_callback_add(id, "delay,changed", index_changed2, NULL);
	evas_object_smart_callback_add(id, "changed", index_changed, NULL);
	evas_object_smart_callback_add(id, "selected", index_selected, NULL);
	elm_index_item_go(id, 0);
	
	//add a hbox
	hbox = elm_box_add(app_cat_win);
	elm_box_horizontal_set(hbox, 1);
	elm_box_homogenous_set(hbox, 1);
	evas_object_size_hint_weight_set(hbox, 1.0, 0.0);
	evas_object_size_hint_align_set(hbox, -1.0, 0.0);
	elm_box_pack_end(vbox, hbox);
	evas_object_show(hbox);

	//add set category button
	bt = elm_button_add(app_cat_win);
	elm_button_label_set(bt, "Set Category");
	evas_object_size_hint_weight_set(bt, 1.0, 0.0);
	evas_object_size_hint_align_set(bt, -1.0, -1.0);
	elm_box_pack_end(hbox, bt);
	evas_object_show(bt);
	evas_object_smart_callback_add(bt, "clicked", set_con_category_clicked, con_list);	
	
	//add cancel button
	cancel_button = elm_button_add(app_cat_win);
	elm_button_label_set(cancel_button, "Done");
	evas_object_size_hint_weight_set(cancel_button, 1.0, 0.0);
	evas_object_size_hint_align_set(cancel_button, -1.0, -1.0);
	elm_box_pack_end(hbox, cancel_button);
	evas_object_show(cancel_button);
	wl.win = app_cat_win;
	wl.li = con_list;
	evas_object_smart_callback_add(cancel_button, "clicked", cancel_button_clicked, &wl);

	//set delete callback for this window
	evas_object_smart_callback_add(app_cat_win, "delete-request", cancel_button_clicked, &wl);
	populate_contact_cat_list(con_list);

	evas_object_show(app_cat_win);
}

void add_edit_contact(void *data, Evas_Object *obj, void *event_info)
{
	Evas_Object *bg, *hbox, *vbox, *button, *tb, *lb, *name_en, *num_en, *email_en, *cat_en, *bday_en, *anniv_en;
	static Winlist wl;
	_act_element *da = (_act_element *)data;
	char nam[255], num[255], win_tit[255], *ty;

	if ((strcmp(da->action, "Add to Contacts") ==0) || (strcmp(da->action, "Add to Contacts SMS") ==0)) {
		strcpy(nam, " Enter Name ");
		ty = strchr(da->num, ':');
		if(ty) {
			ty++;
			strcpy(num, ty);
		}
		else strcpy(num, da->num);
		strcpy(win_tit, "Add Contact");
	}
	else if (strcmp(da->action, "Edit Contact") ==0) {
		strcpy(nam, da->name);
		strcpy(num, da->num);
		strcpy(win_tit, "Edit Contact");
	}
	else if (strcmp(da->action, "new") ==0) {
		strcpy(nam, " Enter Name ");
		strcpy(num, " Tel Number ");
		strcpy(win_tit, "New Contact");
	}
	add_con_win = elm_win_add(NULL, "contacts", ELM_WIN_BASIC);
	elm_win_title_set(add_con_win, win_tit);
	elm_win_autodel_set(add_con_win, 1);

	//get_contact_data();
	
	//add background
	bg = elm_bg_add(add_con_win);
	elm_win_resize_object_add(add_con_win, bg);
	evas_object_size_hint_weight_set(bg, 1.0, 1.0);
	evas_object_show(bg);

	//add vbox 
	vbox = elm_box_add(add_con_win);
	elm_win_resize_object_add(add_con_win, vbox);
	evas_object_size_hint_weight_set(vbox, 1.0, 1.0);
	evas_object_show(vbox);
	
	//add a table
	tb = elm_table_add(add_con_win);
	elm_win_resize_object_add(add_con_win, tb);
	evas_object_size_hint_weight_set(tb, 1.0, 1.0);
	elm_box_pack_end(vbox, tb);
	evas_object_show(tb);

	//add a label
	lb = elm_label_add(add_con_win);
	elm_label_label_set(lb, "Name: ");
	elm_table_pack(tb, lb, 0, 0, 1, 1);
	evas_object_show(lb);

	//add an entry
	name_en = elm_entry_add(add_con_win);
	elm_entry_single_line_set(name_en, 1);
	elm_table_pack(tb, name_en, 1, 0, 2, 1);
	elm_entry_entry_set(name_en, nam);
	evas_object_show(name_en);
	if (strcmp(nam, " Enter Name ") ==0) elm_entry_select_all(name_en);
	
	//add a label
	lb = elm_label_add(add_con_win);
	elm_label_label_set(lb, "Tel No: ");
	elm_table_pack(tb, lb, 0, 1, 1, 1);
	evas_object_show(lb);

	//add an entry
	num_en = elm_entry_add(add_con_win);
	elm_entry_single_line_set(num_en, 1);
	elm_table_pack(tb, num_en, 1, 1, 2, 1);
	elm_entry_entry_set(num_en, num);
	evas_object_show(num_en);
	//if (strcmp(num, " Enter Tel Number ") ==0) elm_entry_select_all(num_en);	

	//add a label
	lb = elm_label_add(add_con_win);
	elm_label_label_set(lb, "email: ");
	elm_table_pack(tb, lb, 0, 2, 1, 1);
	evas_object_show(lb);

	//add an entry
	email_en = elm_entry_add(add_con_win);
	elm_entry_single_line_set(email_en, 1);
	elm_table_pack(tb, email_en, 1, 2, 2, 1);
	//elm_entry_entry_set(email_en, da->email);
	evas_object_show(email_en);

	//add a label
	lb = elm_label_add(add_con_win);
	elm_label_label_set(lb, "Birthday: ");
	elm_table_pack(tb, lb, 0, 3, 1, 1);
	evas_object_show(lb);

	//add an entry
	bday_en = elm_entry_add(add_con_win);
	elm_entry_single_line_set(bday_en, 1);
	elm_table_pack(tb, bday_en, 1, 3, 2, 1);
	//elm_entry_entry_set(bday_en, bday);
	evas_object_show(bday_en);

	//add a label
	lb = elm_label_add(add_con_win);
	elm_label_label_set(lb, "Anniversary: ");
	elm_table_pack(tb, lb, 0, 4, 1, 1);
	evas_object_show(lb);

	//add an entry
	anniv_en = elm_entry_add(add_con_win);
	elm_entry_single_line_set(anniv_en, 1);
	elm_table_pack(tb, anniv_en, 1, 4, 2, 1);
	//elm_entry_entry_set(anniv_en, anniv);
	evas_object_show(anniv_en);

	//add a label
	lb = elm_label_add(add_con_win);
	elm_label_label_set(lb, "Category: ");
	elm_table_pack(tb, lb, 0, 5, 1, 1);
	evas_object_show(lb);

	//add a hover
	cat_en = elm_entry_add(add_con_win);
	elm_entry_single_line_set(cat_en, 1);
	elm_table_pack(tb, cat_en, 1, 5, 2, 1);
	//elm_entry_entry_set(cat_en, cat);
	evas_object_show(cat_en);
	
	//add hbox to vbox
	hbox = elm_box_add(add_con_win);
	elm_box_horizontal_set(hbox, 1);
	evas_object_size_hint_weight_set(hbox, 1.0, 0.0);
	evas_object_size_hint_align_set(hbox, -1.0, 0.0);
	elm_box_pack_end(vbox, hbox);
	evas_object_show(hbox);
	
	//add save button
	button = elm_button_add(add_con_win);
	elm_button_label_set(button, "Save");
	evas_object_size_hint_weight_set(button, 1.0, 1.0);
	evas_object_size_hint_align_set(button, -1.0, -1.0);
	elm_box_pack_end(hbox, button);
	evas_object_show(button);
	con_save.name_en = name_en;
	con_save.num_en = num_en;
	strcpy(con_save.action, da->action);
	strcpy(con_save.path, da->path);
	evas_object_smart_callback_add(button, "clicked", save_contact, NULL);
	
	//add cancel button
	button = elm_button_add(add_con_win);
	elm_button_label_set(button, "Cancel");
	evas_object_size_hint_weight_set(button, 1.0, 1.0);
	evas_object_size_hint_align_set(button, -1.0, -1.0);
	elm_box_pack_end(hbox, button);
	evas_object_show(button);
	wl.win = add_con_win;
	wl.li = NULL;
	evas_object_smart_callback_add(button, "clicked", cancel_button_clicked, &wl);

	// make window full screen
	evas_object_resize(add_con_win, 480, 640);
	evas_object_show(add_con_win);
}

void set_contact(void *data, Evas_Object *obj, void *event_info)
{
	//loop through selected contacts and add to sms_rec_list
	int n, i=0;
	const Eina_List *item;
	_contact *con;

	item = elm_genlist_selected_items_get(contact_list);
	n = eina_list_count(item);

	//for the dynamic array
	free (Con_Sms);
	Con_Sms = (_con_sms *) malloc(sizeof(_con_sms) * n);
	
	while((item)) {
		con = (_contact *)elm_genlist_item_data_get(item->data);
		if (con) {
			strcpy(Con_Sms[i].name, con->name);
			strcpy(Con_Sms[i].p_no, con->phone);
			elm_genlist_item_append(sms_rec_list, &itc_sms_rec, &Con_Sms[i], NULL, 
		                        ELM_GENLIST_ITEM_NONE, NULL, NULL);
			elm_genlist_item_del(item->data);
		}
		item = elm_genlist_selected_items_get(contact_list);
		i++;
	}
	count_sms_con = i;
	//close contact app window
	evas_object_del(contact_win);
}

char *contact_label_get(const void *data, Evas_Object *obj, const char *part)
{
	char *ty=NULL, tystr[255], dt[40], format[40];
	_contact *con = (_contact *)data;
	struct tm *loctime;
	
	if (!strcmp(part, "elm.text")) {
		ty = strdup(con->name);
	}
	else if (!strcmp(part, "elm.text.sub")) {
		time_t p_time = atof(con->time);
		if (p_time != 0) {
			loctime = localtime (&p_time);
			sprintf(format, "%s %s", f_date, f_time);
			strftime(dt, 40, format, loctime);
			if(con->out) sprintf(tystr, "%s   %s-->%s", con->phone, con->type, dt);
			else sprintf(tystr, "%s   %s<--%s", con->phone, con->type, dt);
		}
		else strcpy(tystr, con->phone);		
		ty = strdup(tystr);
	}
	return (ty);
}

Evas_Object *contact_icon_get(const void *data, Evas_Object *obj, const char *part)
{
	//char buf[255];
	//Evas_Object *ic = elm_icon_add(obj);
	
	/*if (!strcmp(part, "elm.swallow.icon")) {
		snprintf(buf, sizeof(buf), "%s/contact.png", "/usr/share/launcher");
		elm_icon_file_set(ic, buf, NULL);
		evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
		return ic;
	}
	else*/ return NULL;
}

Eina_Bool contact_state_get(const void *data, Evas_Object *obj, const char *part)
{
   return 0;
}

void contact_del (const void *data, Evas_Object *obj)
{
}

void contacts_app(void *data, Evas_Object *obj, void *event_info)
{
	Evas_Object *bg, *vbox, *hbox, *button;
	static Winlist wl;

	char *new_sms_da = (char *)data;
	contact_win = elm_win_add(NULL, "contacts", ELM_WIN_BASIC);
	if (strcmp(new_sms_da, "select") == 0) elm_win_title_set(contact_win, "Select Contact");
	else elm_win_title_set(contact_win, "Contacts");
	elm_win_autodel_set(contact_win, 1);
	
	//add background
	bg = elm_bg_add(contact_win);
	elm_win_resize_object_add(contact_win, bg);
	evas_object_size_hint_weight_set(bg, 1.0, 1.0);
	evas_object_show(bg);

	//add vbox 
	vbox = elm_box_add(contact_win);
	elm_win_resize_object_add(contact_win, vbox);
	evas_object_size_hint_weight_set(vbox, 1.0, 1.0);
	evas_object_show(vbox);

	if (strcmp(new_sms_da, "select") != 0) {
		//add a toolbar
		contact_toolbar = elm_toolbar_add(contact_win);
		evas_object_size_hint_weight_set(contact_toolbar, 1.0, 0.0);
		evas_object_size_hint_align_set(contact_toolbar, -1.0, 1.0);
		elm_scroller_bounce_set(contact_toolbar, 0, 0);
		elm_box_pack_end(vbox, contact_toolbar);
		add_contact_toolbar_items();
		evas_object_show(contact_toolbar);
	}	

	//add list to vbox now
	contact_list = elm_genlist_add(contact_win);
	elm_genlist_bounce_set(contact_list, 0, 0);
	//elm_genlist_always_select_mode_set(contact_list, 1);
	evas_object_size_hint_weight_set(contact_list, 1.0, 1.0);
	evas_object_size_hint_align_set(contact_list, -1.0, -1.0);
	elm_box_pack_end(vbox, contact_list);
	evas_object_show(contact_list);
	strcpy(act_da.type, "con");
	act_da.li = contact_list;
	//if (strcmp(new_sms_da, "select") != 0) evas_object_smart_callback_add(contact_list, "selected", show_actions, &act_da);

	//add index
	id = elm_index_add(contact_win);
	evas_object_size_hint_weight_set(id, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_win_resize_object_add(contact_win, id);
	evas_object_show(id);

	evas_object_smart_callback_add(id, "delay,changed", index_changed2, NULL);
	evas_object_smart_callback_add(id, "changed", index_changed, NULL);
	evas_object_smart_callback_add(id, "selected", index_selected, NULL);
	elm_index_item_go(id, 0);
	
	//genlist class defs
	itc_contact.item_style     	= "double_label";
	itc_contact.func.label_get 	= contact_label_get;
	itc_contact.func.icon_get  	= contact_icon_get;
	itc_contact.func.state_get 	= contact_state_get;
	itc_contact.func.del      	= contact_del;
	
	//add hbox to vbox
	hbox = elm_box_add(contact_win);
	elm_box_horizontal_set(hbox, 1);
	elm_box_homogenous_set(hbox, 1);
	evas_object_size_hint_weight_set(hbox, 1.0, 0.0);
	evas_object_size_hint_align_set(hbox, -1.0, 0.0);
	elm_box_pack_end(vbox, hbox);
	evas_object_show(hbox);

	if (strcmp(new_sms_da, "select") == 0) {
		//set contact_list to multi select
		elm_genlist_multi_select_set(contact_list, 1);
		
		//add button to select contact
		button = elm_button_add(contact_win);
		elm_button_label_set(button, "Select");
		evas_object_size_hint_weight_set(button, 1.0, 1.0);
		evas_object_size_hint_align_set(button, -1.0, -1.0);
		elm_box_pack_end(hbox, button);
		evas_object_show(button);
		evas_object_smart_callback_add(button, "clicked", set_contact, NULL);
		
		//add button to jump to name
		/*button = elm_button_add(contact_win);
		elm_button_label_set(button, "Jump!");
		evas_object_size_hint_weight_set(button, 1.0, 1.0);
		evas_object_size_hint_align_set(button, -1.0, -1.0);
		elm_box_pack_end(hbox, button);
		evas_object_show(button);
		evas_object_smart_callback_add(button, "clicked", jump, contact_list);*/

		//add button to edit contact
		button = elm_button_add(contact_win);
		elm_button_label_set(button, "Edit");
		evas_object_size_hint_weight_set(button, 1.0, 1.0);
		evas_object_size_hint_align_set(button, -1.0, -1.0);
		elm_box_pack_end(hbox, button);
		evas_object_show(button);
		//evas_object_smart_callback_add(button, "clicked", jump, contact_list);

		//add button to cancel
		button = elm_button_add(contact_win);
		elm_button_label_set(button, "Cancel!");
		evas_object_size_hint_weight_set(button, 1.0, 1.0);
		evas_object_size_hint_align_set(button, -1.0, -1.0);
		elm_box_pack_end(hbox, button);
		evas_object_show(button);
		wl.win = contact_win;
		wl.li = NULL;
		evas_object_smart_callback_add(button, "clicked", cancel_button_clicked, &wl);
		get_cat_contacts("All");
	}

	else {
		//set contact_list to multi select
		elm_genlist_multi_select_set(contact_list, 0);
		
		//add button to add new contact
		button = elm_button_add(contact_win);
		elm_button_label_set(button, "New");
		evas_object_size_hint_weight_set(button, 1.0, 1.0);
		evas_object_size_hint_align_set(button, -1.0, -1.0);
		elm_box_pack_end(hbox, button);
		evas_object_show(button);
		strcpy(con_data.name, "");
		strcpy(con_data.num, "");
		strcpy(con_data.path, "");
		strcpy(con_data.action, "new");
		evas_object_smart_callback_add(button, "clicked", add_edit_contact, &con_data);

		//add button to jump to name
		/*button = elm_button_add(contact_win);
		elm_button_label_set(button, "Jump!");
		evas_object_size_hint_weight_set(button, 1.0, 1.0);
		evas_object_size_hint_align_set(button, -1.0, -1.0);
		elm_box_pack_end(hbox, button);
		evas_object_show(button);
		evas_object_smart_callback_add(button, "clicked", jump, contact_list);*/
		
		//add button for actions
		button = elm_button_add(contact_win);
		elm_button_label_set(button, "Actions");
		evas_object_size_hint_weight_set(button, 1.0, 1.0);
		evas_object_size_hint_align_set(button, -1.0, -1.0);
		elm_box_pack_end(hbox, button);
		evas_object_show(button);
		evas_object_smart_callback_add(button, "clicked", show_actions, &act_da);
		
		//add cancel button
		button = elm_button_add(contact_win);
		elm_button_label_set(button, "Done");
		evas_object_size_hint_weight_set(button, 1.0, 1.0);
		evas_object_size_hint_align_set(button, -1.0, -1.0);
		elm_box_pack_end(hbox, button);
		evas_object_show(button);
		wl.win = contact_win;
		wl.li = NULL;
		evas_object_smart_callback_add(button, "clicked", cancel_button_clicked, &wl);
		elm_toolbar_item_select(cat_tb_item);
	}

	evas_object_resize(contact_win, 480, 640);
	evas_object_show(contact_win);
}

